package com.example.springboot.controller;

import org.springframework.web.bind.annotation.*;
import com.example.springboot.common.Result;
import javax.annotation.Resource;
import java.io.IOException;
import com.example.springboot.service.IPatentService;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/patent")
    public class PatentController {
    
    @Resource
    private IPatentService patentService;

    //查找所有
    @GetMapping
    public Result findAll() {
        return Result.success(patentService.list());
    }

    //根据id查找
    @GetMapping("/{id}")
    public Result findOne(@PathVariable String id) {
        return Result.success(patentService.getById(id));
    }

    //关键词搜索
    @GetMapping("/searchByWords")
    public Result searchByWords(@RequestParam(defaultValue = "1") int PageNum,
                                @RequestParam(defaultValue = "10") int PageSize,
                                @RequestParam(defaultValue = "") String words) throws IOException {
        return patentService.searchByWords(PageNum,PageSize,words);
    }


    //关键词搜索#新新
    @GetMapping("/searchByKeyWords")
    public Result searchByKeyWords(@RequestParam(defaultValue = "1") int PageNum,
                                   @RequestParam(defaultValue = "10") int PageSize,
                                   @RequestParam(defaultValue = "") String words) throws IOException {
        return patentService.searchByKeyWords(PageNum,PageSize,words);
    }
}



